package com.kaifamiao.ioc.creation.test;

import com.kaifamiao.ioc.creation.Human;
import com.kaifamiao.ioc.creation.Sun;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.time.LocalDate;
import java.util.Calendar;
import java.util.Date;

public class StaticFactoryMethod {

    public static void main( String[] args ) {

        String configs = "classpath*:com/**/static-factory-method.xml";
        // 创建 Spring 容器
        ApplicationContext container = new ClassPathXmlApplicationContext(configs);

        // 从 Spring 容器获得指定名称指定类型的 bean
        Calendar cal = container.getBean( "calendar", Calendar.class );
        System.out.println( cal.get( Calendar.YEAR ) );

        LocalDate birthdate = container.getBean( "birthdate", LocalDate.class );
        System.out.println( birthdate );

        Sun sun = container.getBean( "sun", Sun.class );
        System.out.println( sun );

    }

}
